home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_10_10
/
1010058a
< prev
next >
Wrap
Text File
|
1992-08-08
|
454b
|
20 lines
/* FILE: crc32.c
DATE: 910917:1824
LMOD: 911202:1147
FOR: crc-32 of a named file (Microsoft C)
*/
#include <fcntl.h>
#include <io.h>
/* Given a filename and a buffer, produce a CRC */
long crc32(char *fn,char *buf,int len)
{
int fd,rd; long crc,upd32();
if((fd = open(fn,O_BINARY|O_RDONLY)) < 0)
return(0);
for(crc = 0xffffffffL; (rd = read(fd,buf,len)) > 0;
crc = upd32(crc,buf,rd)) ;
close(fd);
return(~crc);
}